package pl.softech.gpw.candles.editor.dad;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JComponent;
import javax.swing.TransferHandler;

import pl.softech.gpw.candles.editor.CandlestickScene;
import pl.softech.gpw.candles.editor.CandlestickWidget;

public class DragAndDropSupport {

    public static void addSupport(CandlestickWidget widget) {
        widget.getWidget().setTransferHandler(new CWidgetTransferHandler());
        widget.getWidget().addMouseMotionListener(new MouseAdapter() {
            @Override
            public void mouseDragged(MouseEvent e) {
               JComponent c = (JComponent) e.getSource();
               c.getTransferHandler().exportAsDrag(c, e, TransferHandler.COPY);
            }
        });
    }

    public static void addSceneSupport(CandlestickScene scene) {
        scene.getScene().setTransferHandler(new SceneTransferHandler(scene));
    }

}
